package ch.selise.exercise.pattern.notepad.command.impl;

import java.util.Scanner;

import ch.selise.exercise.pattern.notepad.command.BaseCommand;
import ch.selise.exercise.pattern.notepad.storage.AppStorageSingleton;

public class AddCommand extends BaseCommand // implements IUndoableCommand
{

	public AddCommand(String text) {
		super.setText(text);
	}

	public AddCommand(Scanner in) {
		super.setText(in.nextLine());
	}

	@Override
	public void execute() {
		super.setIndex(AppStorageSingleton.getInstance().addText(
				super.getText()));

		//AppStorageSingleton.getInstance().addCommand(this);
	}

	@Override
	public void undoCommand() {
		AppStorageSingleton.getInstance().removeText(super.getIndex());
	}

	/*
	 * @Override public void redoCommand() { this.execute(); }
	 */

}
